<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with assignment 3]]></title><description><![CDATA[A list of topics that have been tagged with assignment 3]]></description><link>https://community.secnto.com//tags/assignment 3</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 18:19:40 GMT</lastBuildDate><atom:link href="https://community.secnto.com//tags/assignment 3.rss" rel="self" type="application/rss+xml"/><pubDate>Invalid Date</pubDate><ttl>60</ttl><item><title><![CDATA[CS201 Assignment 3 Solution and Discussion]]></title><description><![CDATA[@zaasmi said in CS201 Assignment 3 Solution and Discussion:

Re: CS201 Assignment 3 Solution and Discussion
Assignment No.  3
Semester: Fall 2020
CS201 – Introduction to Programming	Total Marks: 20
Due Date:
29-01-2021
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
o	Assignment is submitted after due date.
o	Submitted assignment does not open or file is corrupt.
o	Assignment is copied (From internet/students).
o	Assignment is not in .cpp format.
Software allowed to develop Assignment

Dev C++

Objectives:
In this assignment, the students will learn:
•	Use of class in programming
•	How to deal with a file in programming
•	How to implement switch statement for Class based functions.
ABC bakery is using a console based inventory management system for the receipt generation purposes. Console application will help the cashier in calculating total price of each item with respect to its price. Menu list will provide Add an item  option to take data about an inventory item, include Item Id, Item name, price and quantity. Relevant data of all items will be displayed on screen with the help of menu option. Quantity amount of items will changeable if user wants to add quantity of an item.
Problem Statement
Write a C++ program to manage the inventory item using your knowledge about file handling and classes. User will manage details of an Inventory item using menu list that will provide three options:
ENTER CHOICE

ADD AN INVENTORY ITEM
DISPLAY FILE DATA
INCREASE QUANTITY

Prompt will show to the user for continue the program after dealing with each option, until user will press a key other than ‘y’.
Instructions to write C++ program:
You will use class “Inventory” to declare inventory data and info
Make “Inventory.txt” file to save inventory item record
“Inventory.txt” file will delete each time when the program will run
“ERROE IN OPENING FILE” will be shown if user not press ‘1’ when program will execute first time.
You will use switch statement to handle different conditions and to perform different actions based on the different actions, that is, choice 1, 2, and 3.
Code structure [ Demonstration]:
You will be using the following class and other functions to  develop the assignment:
class Inventory
{
      private:
              int itemID;
              char itemName[20];
              float itemPrice;
              float quantity;
              float totalPrice;

      public:
             void readItem();
             void displayItem();
             int getItemID() ;
             float getPrice() ;
             float getQuantity() ;
            void updateQuantity(float q);    
};

//Deleting existing file
void deleteExistingFile(){--------}

//Appending item in file
void appendToFille(){------------}

//Displaying items
void displayAll(){------------}

//Increasing Quantity of item
void increaseQuanity(){------------}

Program Output:


User’s prompt when program will execute for the first time.
[image: Rokeghr.png]


When user press ‘1’ ,  It will take data about an inventory item as an input from the user.
[image: wryzxvA.png]


When user press ‘2’, it will read data from “Inventory.txt” file and display record of all inventory items on the screen
[image: hxs7hvH.png]


If user press ‘3’, it will ask to enter Item id against which user want to increase item quantity.
[image: tDlho0s.png]


Now, when the user will press ‘2’, the inventory item record will be shown as:
[image: hQCSrHs.png]


Assignment#3 covers course contents from lecture 17 to 30.
Best of Luck!

#include&lt;iostream&gt;
#include&lt;fstream&gt;
#include&lt;stdio.h&gt;
 
using namespace std;

class Inventory
{
      private:
              int itemID;
              char itemName[20];
              float itemPrice;
              float quantity;
              float totalPrice;
      public:
             void readItem();
             void displayItem();
             int getItemID()   { return itemID;}
             float getPrice()    { return itemPrice;}
             float getQuantity()    { return quantity;}
             void updateQuantity(float q)    
             { 
                  quantity=q;
                  totalPrice = (itemPrice*quantity);
             }
};

//    Getting Item 
void Inventory::readItem(){
    cout &lt;&lt; "Please enter item id: ";
    cin &gt;&gt; itemID;
    cout &lt;&lt; "Please enter item name: ";
    cin.ignore(1);
    cin.getline(itemName,20);
    cout &lt;&lt; "Please enter price: ";
    cin &gt;&gt; itemPrice;
    cout &lt;&lt; "Please enter quantity: ";
    cin &gt;&gt; quantity;
    totalPrice = (itemPrice*quantity);
}

//  Displaying Item
void Inventory::displayItem()
{
    cout &lt;&lt; "Item id:" &lt;&lt; itemID &lt;&lt; "\tItem name:" &lt;&lt; itemName &lt;&lt; "\t ItemPrice:" &lt;&lt; itemPrice &lt;&lt; "\t Quantity:" &lt;&lt; quantity &lt;&lt; "\t TotalPrice:" &lt;&lt; totalPrice &lt;&lt; endl;
}

//  Deleting existing file
void deleteExistingFile(){
    remove("Inventory.txt");
}

//  Appending item in file
void appendToFille(){
     Inventory x;
     x.readItem();
  
     ofstream file;   
     file.open("Inventory.txt",ios::binary | ios::app);

    if(!file){
        cout &lt;&lt; "ERROR WHILE CREATING A FILE!\n";
        return;
    }
    
    file.write((char*)&amp;x,sizeof(x));
    file.close();
    cout&lt;&lt;"Inventory record(s) added sucessfully.\n";
}

//  Displaying items
void displayAll(){
    Inventory x;
    ifstream file;
    file.open("Inventory.txt",ios::binary | ios::in);

    if(!file){
        cout&lt;&lt;"ERROR IN OPENING FILE \n";
        return;
    }
    while(file){
    if(file.read((char*)&amp;x,sizeof(x)))
       x.displayItem();
    }
  file.close();
}

//  Increasing Quantity of item
void increaseQuanity(){
    int itemValue;
    int isFound=0;
    int q;
    Inventory x;
 
    cout&lt;&lt;"Enter item id: \n";
    cin &gt;&gt; itemValue;
 
    ifstream fileRead;
    fileRead.open("Inventory.txt",ios::binary | ios::in);
    
    if(!fileRead){
        cout&lt;&lt;"ERROR IN OPENING FILE \n";
        return;
    }
    
    while(fileRead){    
        if(fileRead.read((char*)&amp;x,sizeof(x))){
            if(x.getItemID() == itemValue){
                cout &lt;&lt; "Add quantity? ";
                cin &gt;&gt; q;
                x.updateQuantity(x.getQuantity() + q); 
                isFound=1;
                break;
            }
        }
    }
    
    if(isFound==0){
        cout&lt;&lt;"Record not found!!!\n";
    }

    fileRead.close();

    deleteExistingFile();

    ofstream fileWrite;
    fileWrite.open("Inventory.txt",ios::binary | ios::app);
    fileWrite.write((char*)&amp;x,sizeof(x));

    fileWrite.close();
    cout &lt;&lt; "Item Quantity updated successfully."&lt;&lt;endl;
}

int main()
{
     char ch;
    
    
     do
     {
      char n;
      
 
      cout &lt;&lt; "ENTER CHOICE\n" &lt;&lt; "1. ADD AN INVENTORY ITEM\n" &lt;&lt; "2. DISPLAY FILE DATA\n" &lt;&lt; "3. INCREASE QUANTITY\n";
      cout &lt;&lt; "Please select a choice: ";
    
      cin &gt;&gt; n;

      switch(n)
      {
          case '1':
            appendToFille();
            break;
          case '2' :
            displayAll();
            break;
          case '3':
          	increaseQuanity();
            break;
           default :
                cout &lt;&lt; "Invalid Choice\n";
                break;
      }
   
  /*    else
      cout&lt;&lt;"Enter integer value only";
      }
 */
     cout &lt;&lt; "Do you want to continue? : ";
     cin &gt;&gt; ch;
 
     }
     while(ch=='Y'||ch=='y');
     
    return 0;
    
    
}


]]></description><link>https://community.secnto.com//topic/2199/cs201-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2199/cs201-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS607 Assignment 3 Solution and Discussion]]></title><description><![CDATA[https://www.youtube.com/watch?v=wJmGSlgXnmQ
]]></description><link>https://community.secnto.com//topic/2183/cs607-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2183/cs607-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS301 Assignment 3 Solution and Discussion]]></title><description><![CDATA[CS301-assignment-no3-Solution.docx
]]></description><link>https://community.secnto.com//topic/2155/cs301-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2155/cs301-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Need CS408 Assignment 3 Solution 2020]]></title><description><![CDATA[Last date
]]></description><link>https://community.secnto.com//topic/2038/need-cs408-assignment-3-solution-2020</link><guid isPermaLink="true">https://community.secnto.com//topic/2038/need-cs408-assignment-3-solution-2020</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS101 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Assignment 3 solution 2021 https://youtu.be/1TNXNoBFry0
]]></description><link>https://community.secnto.com//topic/2030/cs101-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2030/cs101-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[cyberian]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[BIO731 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Please share idea
]]></description><link>https://community.secnto.com//topic/2024/bio731-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2024/bio731-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS614 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Please share your idea solution
]]></description><link>https://community.secnto.com//topic/2006/cs614-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2006/cs614-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS606 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Discussion is right way to get Solution of the every assignment, Quiz and GDB.
We are always here to discuss and Guideline, Please Don’t visit Cyberian only for Solution.
Cyberian Team always happy to facilitate to provide the idea solution. Please don’t hesitate to contact us!
NOTE: Don’t copy or replicating idea solutions.
]]></description><link>https://community.secnto.com//topic/2004/cs606-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2004/cs606-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS604 Assignment 3 Solution and Discussion]]></title><description><![CDATA[idea solution plz
]]></description><link>https://community.secnto.com//topic/2001/cs604-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2001/cs604-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Ch. Robika]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS508 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Please share ideas solution
]]></description><link>https://community.secnto.com//topic/2000/cs508-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2000/cs508-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Tahir Baloch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS420 Assignment 3 Solution and Discussion]]></title><description><![CDATA[ideas share car do plz
]]></description><link>https://community.secnto.com//topic/1999/cs420-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1999/cs420-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Reda Aamir]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS402 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Solution:
[image: Q6aVBO6.png]
[image: PB7zJDO.png]
[image: XnCOX5j.png]
[image: KG4WE2y.png]
[image: kagU2d1.png]
[image: FdZJjgG.png]
[image: GgAlx12.png]
[image: JkCiwJs.png]
[image: oyMNZdX.png]
[image: Te4WVHR.png]
]]></description><link>https://community.secnto.com//topic/1998/cs402-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1998/cs402-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS312 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Idea solution please
]]></description><link>https://community.secnto.com//topic/1997/cs312-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1997/cs312-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Mehr Ali]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS001 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Please share idea solution
]]></description><link>https://community.secnto.com//topic/1996/cs001-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1996/cs001-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Faaizaa]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 3 Solution and Discussion]]></title><description><![CDATA[CS201 ASSIGNMENT 3 SOLUTION SPRING 2021
#include &lt;iostream&gt;
using namespace std;
#define PI 3.14159265

class Circle

{
	private:
		double radius;
	public:
		void setRadius(); 
		void computeAreaCirc();
		
		Circle();	
		~Circle();
};

Circle::Circle()
{
	radius = 0.0;
}

void Circle::setRadius()
{
	
	radius = 5.6;
}

void Circle::computeAreaCirc()
{
	cout &lt;&lt; "Area of circle is: " &lt;&lt; PI * (radius * radius) &lt;&lt; endl;
	
	cout &lt;&lt; "Circumference of circle is: " &lt;&lt; 2 * PI * radius &lt;&lt; endl;

}

Circle::~Circle()
{
	
}

class Rectangle
{
	private:
		double length; 
		double width;
	public:
		void setLength(); 
		void setWidth();
		void computeArea();
		
		Rectangle();
		~Rectangle();
	
};

Rectangle::Rectangle()
{
	length = 0.0;
	width = 0.0;
}

void Rectangle::setLength()
{
	length = 5.0;
	
}

void Rectangle::setWidth()
{
	width = 4.0;
}

void Rectangle::computeArea()
{
	cout &lt;&lt; "Area of Rectangle: " &lt;&lt; length * width &lt;&lt; endl;	
}

Rectangle::~Rectangle()
{
	
}

main()
{
	cout&lt;&lt;"********************SCIENTIFIC CALCULATOR********************"&lt;&lt;endl;
	cout&lt;&lt;""&lt;&lt;endl;
	int run = 1;
	string option, choice;
	
	while(run)
	{
		cout &lt;&lt; "\nOPTION 1 for computing Area and Circumference of the circle" &lt;&lt; endl;
		cout &lt;&lt; "OPTION 2 for computing Area of the Rectangle" &lt;&lt; endl;
		cout &lt;&lt; "Select your desired option(1-2): ";
		cin &gt;&gt; option;
		
		if(option == "1")
		{
			Circle nCircle;
			nCircle.setRadius();
			nCircle.computeAreaCirc();
			cout &lt;&lt; "Do you want to perform anyother calculation(Y/N):";
			cin &gt;&gt; choice;
			if(choice == "Y" || choice == "y")
			{
				continue;
			}
			
			else
			{
				break;
			}
			
		}
		else if(option == "2")
		{
			Rectangle nRectangle;
			nRectangle.setLength();
			nRectangle.setWidth();
			nRectangle.computeArea();
			cout &lt;&lt; "Do you want to perform anyother calculation(Y/N):";
			cin &gt;&gt; choice;
			if(choice == "Y" || choice == "y")
			{
				continue;
			}
			else
			{
				break;
			}
		}
		else
		{
			cout &lt;&lt; "Invalid Option!, Option should be from (1-2)" &lt;&lt; endl;
		}
	}
}


]]></description><link>https://community.secnto.com//topic/1995/cs201-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1995/cs201-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS611 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Solution Ideas Please!
]]></description><link>https://community.secnto.com//topic/1994/cs611-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1994/cs611-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[Wade Wild]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>